package com.liruo.test.spring.annotationdep.cptscan;

import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;
import java.util.Arrays;

/**
 * @Author:liruo
 * @Date:2022-11-20-12:14:17
 * @Desc
 */
public class CustomizeFilterType implements TypeFilter {
    /**
     *
     * @param metadataReader  当前类信息
     * @param metadataReaderFactory  读取其他信息--通过类名或者资源
     * @return
     * @throws IOException
     */
    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
        //当前类注解信息
        AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
        //当前类信息
        ClassMetadata classMetadata = metadataReader.getClassMetadata();
        //当前类所在文件
        Resource resource = metadataReader.getResource();
        String prefix = "---------------------------";
        System.out.println(prefix + classMetadata);
        System.out.println(Arrays.toString(annotationMetadata.getMemberClassNames()));
        return false;
    }
}
